﻿@namespace BlazorCharts
@inherits ElementSeries<TData>
@typeparam TData

@if (Chart.IsInit)
{
<g class="bc-line-series" transform="translate(@Rect.LT.ToPoint())">

    @{
        foreach (var group in SeriesData.Groups)
        {
            var color = (group ?? "Area").RandomColor().Transparent().ToHtml();
            var colorDeepen = (group ?? "Area").RandomColor().Deepen().ToHtml();
            List<Point> points = new List<Point>();


            @*起始点*@
            if (SeriesData.CategoryDatas.Count > 0)
            {
                var first = SeriesData.CategoryDatas.First();
                points.Add(new Point((int)(Chart.BcAxisGroup.AxesX.Rect.W * first.ZeroOffsetRatio), Rect.H));
            }

            @*连线*@
            foreach (var category in SeriesData.CategoryDatas)
            {
                var data = SeriesData.GetValueData<SingleValueData>(category.Name, group);
                points.Add(new Point((int)(Chart.BcAxisGroup.AxesX.Rect.W * category.ZeroOffsetRatio), Rect.H - GetHeightByValue(data.Value)));
            }


            @*结束点*@
            if (SeriesData.CategoryDatas.Count > 1)
            {
                var end = SeriesData.CategoryDatas.Last();
                points.Add(new Point((int)(Chart.BcAxisGroup.AxesX.Rect.W * end.ZeroOffsetRatio), Rect.H));
            }

            <polygon points="@points.ToPoints()" stroke="@color" stroke-width=0 fill="@color" />
        }


    }

</g>

}